<?php
namespace app\api\controller\setting;
use app\common\controller\BaseController;
use app\common\service\setting\MemberHelpService;
use app\common\service\system\SettingService;
use app\common\validate\setting\MemberHelpValidate;
use hg\apidoc\annotation as Apidoc;
/**
 * @Apidoc\Title("帮助中心")
 * @Apidoc\Group("setting")
 * @Apidoc\Sort("250")
 */
class MemberHelp extends BaseController
{
    /**
    * @Apidoc\Title("帮助中心列表")
    * @Apidoc\Query(ref="pagingQuery")
    * @Apidoc\Query(ref="sortQuery")
    * @Apidoc\Query(ref="searchQuery")
    * @Apidoc\Query(ref="dateQuery")
    * @Apidoc\Returned(ref="expsReturn")
    * @Apidoc\Returned(ref="pagingReturn")
    * @Apidoc\Returned("list", type="array", desc="帮助中心列表", children={
    *   @Apidoc\Returned(ref="app\common\model\MemberHelpModel", field="id,title,content,is_disable,create_time,update_time,sort,image_id,remark")
    * })
    */
    public function list()
    {
        $where = $this->where(where_delete());
        $data = MemberHelpService::list($where, $this->page(), $this->limit(), $this->order());
        return success($data);
    }
    /**
    * @Apidoc\Title("帮助中心信息")
    * @Apidoc\Query(ref="app\common\model\MemberHelpModel", field="id")
    * @Apidoc\Returned(ref="app\common\model\MemberHelpModel")
    */
    public function getInfo()
    {
        $param = $this->params(['s_code/s' => '']);
        validate(MemberHelpValidate::class)->scene('getInfo')->check($param);
        $data = MemberHelpService::getInfo($param['s_code']);
        return success($data);
    }
    /**
     * @Apidoc\Title("查询客服信息")
     * @Apidoc\Query(ref="app\common\model\MemberHelpModel", field="id")
     * @Apidoc\Returned(ref="app\common\model\MemberHelpModel")
     */
    public function getServiceInfo()
    {
        $data = SettingService::info('service_type,service_phone,service_qq,service_wechat,service_wechat_image_id,service_wechat_image_url');
        if($data['service_phone']){
            $data['service_phone'] = explode(',',$data['service_phone']);
        }else{
            $data['service_phone'] =[];
        }
        if($data['service_qq']){
            $data['service_qq'] = explode(',',$data['service_qq']);
        }else{
            $data['service_qq'] =[];
        }
        if($data['service_wechat']){
            $data['service_wechat'] = explode(',',$data['service_wechat']);
        }else{
            $data['service_wechat'] =[];
        }
        return success($data);
    }
}
